﻿using P7DC.Entity.Interface;

namespace P7DC.Entity.Entity
{
	public abstract class BaseEntity<TKey> : IEntity<TKey>
	{
		public TKey Id { get; set; }

		public override bool Equals(object obj)
		{
			if (ReferenceEquals(obj, null))
			{
				return false;
			}

			var baseEntity = obj as BaseEntity<TKey>;

			if (ReferenceEquals(baseEntity, null))
			{
				return false;
			}
			
			return Id.Equals(baseEntity.Id);
		}

		public override int GetHashCode()
		{
			return Id.GetHashCode();
		}		
	}
}
